
# 案例：a模式用来在原有的文件内存的基础之上写入新的内容，比如记录日志、注册
# 注册功能
# name=input('your name>>: ')
# pwd=input('your name>>: ')
# with open('db.txt',mode='at',encoding='utf-8') as f:
#     f.write('{}:{}\n'.format(name,pwd))


# 了解：+不能单独使用，必须配合r、w、a
with open('g.txt',mode='rt+',encoding='utf-8') as f:
    print(f.read())
    f.write('中国')

with open('g.txt',mode='w+t',encoding='utf-8') as f:
    f.write('111\n')
    f.write('222\n')
    f.write('333\n')
    print('====>',f.read())


with open('g.txt',mode='a+t',encoding='utf-8') as f:
    print(f.read())

    f.write('444\n')
    f.write('5555\n')
    print(f.read())